package com.media.themovieworld.screen;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.media.themovieworld.R;
import com.media.themovieworld.screen.common.adapter.BaseListAdapter;
import com.media.themovieworld.screen.common.base.MovieWorldScreen;
import com.media.themovieworld.widget.pullandloadmore.LoadMoreListView;
import com.media.themovieworld.widget.slidingmenu.SlidingMenu;

public class TestFragment extends MovieWorldScreen{

	private LoadMoreListView mLoadMoreListView;
	@Override
	protected View onCreateContentView(LayoutInflater inflater,
			ViewGroup container) {
		View root = inflater.inflate(R.layout.tmw__list_efilm_screen, container,false);
		mLoadMoreListView = (LoadMoreListView) root.findViewById(R.id.tmw__list_efilm_list);
		init();
		return root;
	}
	
	private void init(){
		ArrayList<String> arrTest = new ArrayList<String>();
		arrTest.add("ABC");
		arrTest.add("ABC1");
		arrTest.add("ABC2");
		arrTest.add("ABC3");
		arrTest.add("ABC4");
		arrTest.add("ABC5");
		arrTest.add("ABC6");
		arrTest.add("ABC7");
		TestAdapter adapter = new TestAdapter(getActivity(), arrTest);
		mLoadMoreListView.setAdapter(adapter);
	}
	
	class TestAdapter extends BaseListAdapter<String>{

		public TestAdapter(Activity activity, ArrayList<String> datas) {
			super(activity, datas);
		}

		@Override
		public View getView(final int arg0, View convertView, ViewGroup arg2) {
			if(convertView == null){
				convertView = LayoutInflater.from(mActivity).inflate(R.layout.test_sliding_menu, null,false);
			}
			
			SlidingMenu slidingMenu = (SlidingMenu) convertView.findViewById(R.id.slidingmenulayout);
			slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
			TextView tTitle = (TextView) convertView.findViewById(R.id.tTitle);
			TextView tDelete = (TextView) convertView.findViewById(R.id.tDelete);
			tTitle.setText(getItem(arg0));
			tDelete.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					Toast.makeText(mActivity, "Delete Item "+arg0, Toast.LENGTH_SHORT).show();
				}
			});
			return convertView;
		}
		
	}

}
